Interview Questions and Answer
Options:
a. if
b. switch
c. if & switch
d. None of the mentioned
Reveal Answer
Options:
a. if()
b. for()
c. continue
d. break
Reveal Answer
Options:
a. switch statement is more efficient than a set of nested ifs.
b. two case constants in the same switch can have identical values.
c. switch statement can only test for equality, whereas if statement can evaluate any type of boolean expression.
d. it is possible to create a nested switch statements.
Reveal Answer
Options:
a. If a is true and b is true then the output is "A && B"
b. If a is true and b is false then the output is "notB"
c. If a is false and b is true then the output is "ELSE"
d. If a is false and b is false then the output is "ELSE"
Reveal Answer
Options:
a. There is a syntax error on line 1.
b. There are syntax errors on lines 1 and 6.
c. There are syntax errors on lines 1, 6, and 8.
d. There is a syntax error on line 6.
Reveal Answer
Options:
a. int arr[] = new int[5]
b. int [] arr = new int[5]
c. int arr[] = new int[5]
d. int arr[] = int [5] new
Reveal Answer
Options:
a. 0
b. value stored in arr[0].
c. 00000
d. Garbage value
Reveal Answer
Options:
a. 0
b. Compilation error, arrays cannot be initialized to zero size.
c. Compilation error, it is a.length() not a.length
d. None of the above
Reveal Answer
Options:
a. The program has a compile error because the size of the array wasn't specified when declaring the array.
b. The program has a runtime error because the array elements are not initialized.
c. The program runs fine and displays x[0] is 0.
d. The program has a runtime error because the array element x[0] is not defined.
Reveal Answer
Options:
a. 0
b. some junk value
c. error because array
d. error because index must is not initialized be greater than zero
Reveal Answer
Options:
a. A java array is always an object
b. Length of array can be changed after creation of array
c. Arrays in Java are always allocated on heap
Reveal Answer
Bestdotnet google plus